package com.wanmait.recruitment.service.impl;

import com.github.pagehelper.PageInfo;
import com.wanmait.recruitment.mapper.CompanyTagMapper;
import com.wanmait.recruitment.pojo.CompanyTag;
import com.wanmait.recruitment.service.CompanyTagService;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
@Service
@Transactional(rollbackFor = Exception.class)
public class CompanyTaglmpl  implements CompanyTagService {
      @Resource
      private CompanyTagMapper companyTagMapper;

    @Override
    public void insert(CompanyTag object) {

    }

    @Override
    public void delete(Integer id) {

    }

    @Override
    public void delete(String ids) {

    }

    @Override
    @CacheEvict(value = "companyTagCache",allEntries = true)
    public void update(CompanyTag companyTag) {
        companyTagMapper.update(companyTag);
    }

    @Override
    public List<CompanyTag>selectById(Integer id){

        return  companyTagMapper.selectById(id);
   }
    @Override
    public List<CompanyTag>selectByIdTop3(Integer id){

        return  companyTagMapper.selectByIdTop3(id);
    }

    @Override
    @CacheEvict(value = "companyTagCache",allEntries = true)
    public void insert(int companyId, String tagsIds) {
        String[] idStrArr = tagsIds.split(",");
        List<Integer> idList = new ArrayList<>();
        for (String idStr:idStrArr){
            idList.add(Integer.parseInt(idStr));
        }
        companyTagMapper.inset(companyId,idList);
    }

    @Override
    public CompanyTag findById(Integer id) {
        return null;
    }

    @Override
    public List findAll() {
        return null;
    }

    @Override
    public List<CompanyTag> findAll(CompanyTag object) {
        return null;
    }
    @Override
    public PageInfo findPage(int pageNum, int pageSize) {
        return null;
    }
}
